Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

types: per comment, avoid copy when t is not bound #32176

Merged
merged 1 commit into from
May 31, 2019

Conversation

vtjnash
Copy link
Member

@vtjnash vtjnash commented May 29, 2019

As mentioned in #9378, be more careful about not copying objects that are already cached. This should get us the same result, but do strictly less work. And it should address the recursion issue mentioned in #25796, by avoiding making copies of any non-bound objects (which is anything maybe-cacheable) now. It's harder to trigger this now that #31877 is merged, but I think still worthwhile to do the cleanup (and to rely less on that optimization).

As mentioned in #9378.
Fix recursion issue mentioned in #25796 by using inst_datatype_inner
instead of inst_datatype, so that we shouldn't be making copies of
any non-bound objects (anything maybe-cacheable) now.
@vtjnash vtjnash requested a review from JeffBezanson May 29, 2019 18:16
@vtjnash vtjnash force-pushed the jn/25796-fieldtype-comment branch from 0c52cc8 to bccd664 Compare May 29, 2019 18:17
@JeffBezanson JeffBezanson added the types and dispatch Types, subtyping and method dispatch label May 29, 2019
@@ -1287,7 +1306,10 @@ static jl_value_t *inst_datatype_inner(jl_datatype_t *dt, jl_svec_t *p, jl_value
}
else if (cacheable) {
// recursively instantiate the types of the fields
ndt->types = inst_ftypes(ftypes, env, stack);
if (dt->types == NULL)
ndt->types = jl_compute_fieldtypes(ndt);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Curious why this is needed?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's reveled from an interaction of the PR with lazy-ftypes (although just the type-stack alone could theoretically run into the same problem with this PR). Previously, on arriving in this function, the dt was always the wrapper object and so the env was already that which will be created by jl_compute_fieldtypes. With the PR, it now could be a partially computed type that just needs to be copied, but that also means it could now be the final parameter application to create a concrete type (where with lazy-ftypes, we are now not been computing the ftypes of that intermediate work).

@vtjnash vtjnash merged commit 217507f into master May 31, 2019
@vtjnash vtjnash deleted the jn/25796-fieldtype-comment branch May 31, 2019 14:35
@KristofferC
Copy link
Member

This fixes a regression in load time for BandedMatrices (ref #32216) so, if possible, would be good to backport. It doesn't backport cleanly though so perhaps you (@vtjnash) can make a rebased PR or push a backport commit to the backport branch?

JeffBezanson pushed a commit that referenced this pull request Jun 18, 2019
As mentioned in #9378.
Fix recursion issue mentioned in #25796 by using inst_datatype_inner
instead of inst_datatype, so that we shouldn't be making copies of
any non-bound objects (anything maybe-cacheable) now.
(cherry picked from commit 217507f)
KristofferC pushed a commit that referenced this pull request Jun 19, 2019
As mentioned in #9378.
Fix recursion issue mentioned in #25796 by using inst_datatype_inner
instead of inst_datatype, so that we shouldn't be making copies of
any non-bound objects (anything maybe-cacheable) now.
(cherry picked from commit 217507f)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
types and dispatch Types, subtyping and method dispatch
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants